#==== ==== ==== ====
# SMITRAN V 3.0
#==== ==== ==== ====
def smitran_kernel3(s1, s2, data, k, decay):
    kmers1 = data[s1][0]
    kmers2 = data[s2][0]
    inter = set(kmers1).intersection(kmers2)

    charIndexes1 = data[s1][1]
    charIndexes2 = data[s2][1]

    #odkloni = []
    suma1 = 0.0
    suma2 = 0.0

    for ngram in kmers1:
        # Dobi indexe crk iz ngrama
        stringIndexes = [charIndexes2.get(i, []) for i in ngram]

        sskFind = sskFindOut()
        sskFind(-1, stringIndexes)

        odklon = sum([decay ** odklon for odklon in sskFind(True)]) #sum(decay ** sskFind1(True))
        suma1 += odklon

    for ngram in kmers2:
        # Dobi indexe crk iz ngrama
        stringIndexes = [charIndexes1.get(i, []) for i in ngram]

        sskFind = sskFindOut()
        sskFind(-1, stringIndexes)

        odklon = sum([decay ** odklon for odklon in sskFind(True)]) #sum(decay ** sskFind1(True))
        suma2 += odklon

    print (suma1, suma2)
    return (suma1 + suma2) / 2.0

def smit(n1, n2, data):
    return smitran_kernel3(n1, n2, data) / sqrt(smitran_kernel3(n1, n1, data) * smitran_kernel3(n2, n2, data))
